package com.ezerg.proxy;

import java.lang.reflect.Proxy;

public class ProxyTest {

	public static void main(String[] args) {
		//静态代理
		TestService test = new TestServiceImpl();
		TestServiceProxy proxy = new TestServiceProxy(test);
		proxy.proxyTestService();
		//动态
		ProxyInvocationHandler pih = new ProxyInvocationHandler(test);
		TestService test2 = (TestService)Proxy.newProxyInstance(test.getClass().getClassLoader(), test.getClass().getInterfaces(),pih);
		test2.proxy();
	}

}
